/**
 * Created by Veronica on 2017/3/26.
 */
/*P37 ，实现Comparable的Elephant类*/
package app14;
public class Elephant implements Comparable {

        public float weight;
        public int age;
        public float tuskLength;
    public int compareTo (Object obj){
        Elephant anotherElephant = (Elephant) obj;
        if (this.weight > anotherElephant.weight){
            return 1;
        }else if (this.weight < anotherElephant.weight){
            return  -1;
        }else {
            return (this.age - anotherElephant.age);
        }
    }
}
